package com.kerrykidz.system.service.impl;


import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kerrykidz.membership.dao.mapper.CusMemEntityMapper;
import com.kerrykidz.membership.dao.mapper.CusMemSalesEntityMapper;
import com.kerrykidz.membership.dao.model.CusMemEntity;
import com.kerrykidz.membership.dao.model.CusMemSalesEntity;
import com.kerrykidz.system.dao.mapper.SecUsrEntityMapper;
import com.kerrykidz.system.dao.model.SecUsrEntity;
import com.kerrykidz.system.service.ICusMemService;
import com.rdp.framework.exception.RDPException;
@Service
public class CusMemServiceImpl implements ICusMemService{
	@Autowired
	private CusMemEntityMapper cusMemEntityMapper;
	@Autowired
	private CusMemSalesEntityMapper cusMemSalesEntityMapper;
	@Autowired
	private SecUsrEntityMapper secUsrEntityMapper;
	@Override
	public CusMemEntity findBySalesName(CusMemEntity entity)
			throws RDPException {
		entity.setIspaging(true);
		List<CusMemEntity> beanList = cusMemEntityMapper.findBySaleName(entity);
		if(beanList.size()>0){
			entity.setResults(beanList);
		}
		return entity;
	}
	
	
	@Override
	public void updateSalesByMemberId(CusMemSalesEntity entity) throws RDPException {
		cusMemSalesEntityMapper.updateSalesByMemberId(entity);
	}
	
	/**
	 * 根据访客ID查询对应销售
	 * 
	 * @param memberId
	 *            会员编号
	 * @return
	 * @throws RDPException
	 */
	public SecUsrEntity findSaleUserById(@Param("memberId") String memberId) throws RDPException{
		return secUsrEntityMapper.findSaleUserById(memberId);
	}

}
